<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hello World</title>
</head>
<body>
    <div id="app">
        <h3>{{ name }}，欢迎您</h3>
        <div>有 {{ num }} 人给您点赞了</div>
        <div>
            <lab>名字：</lab>
            <input type="text" v-model="name"/>
        </div>
        <button v-on:click="num++">点赞</button>
        <button v-on:click="cancel">取消</button>
    </div>
    <script src="../node_modules/vue/dist/vue.min.js"></script>
    <script>
        let vm = new Vue({
            el: "#app",
            data: {
                name: "张三",
                num: 0
            },
            methods: {
                cancel: function() {
                    let n = this.num;
                    this.num = n > 0 ? --n : n;
                }
            },
        });
    </script>
</body>
</html>